from django.http import HttpResponse
from django.shortcuts import render

import time

def index(request):
    context = {
        'django2_url': [
            'from django.urls import re_path,path',
            "path('', views.index, name='index'),",
            "re_path(r'^$', views.index, name='index'),",
        ],
        'url01': {'路由变量': ['字符类型', '整型', 'slug', 'uuid']}
    }
    return render(request, 'index.html', context=context)


def born(request, year, month, day):
    # context = {
    #     'django2_url': []
    # }
    return HttpResponse(request.path)


def url_outside(request, month):
    print(month)
    return HttpResponse(f'这是路由地址信息之外的变量：{request.path}')


def phone_demo(request, phone_num):
    return HttpResponse(f'正则表达式路由{phone_num}')


def template_url(request):
    t_now = time.localtime()
    print(t_now)
    return HttpResponse(str(t_now))
